package org.hertsig.magiccardmarket.xml;

import java.text.ParseException;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import com.google.common.base.Strings;

public class EmptyStringDoubleAdapter extends XmlAdapter<String, Double> {
	@Override
	public Double unmarshal(String value) throws ParseException {
		return Strings.isNullOrEmpty(value) ? null : Double.parseDouble(value);
	}
	
	@Override
	public String marshal(Double value) {
		return value == null ? "" : value.toString();
	}
}
